<template>
  <div class="div1">
    <!-- <img src="./assets/搜索.png" /> -->
    <van-tabs v-model="active" @click.native="ndetail()">
      <van-tab :title="v.navigationName" v-for="v in navList" :key="v.id"></van-tab>
    </van-tabs>
    <van-search
      disabled
      placeholder="请输入搜索关键词"
      class="search"
      @click.native="search()"
    ></van-search>
    <router-view></router-view>
  </div>
</template>

<script>
import url from "../tools/url";
export default {
  name: "Classify",
  data() {
    return {
      active: 0,
      navList: [],
    };
  },
  methods: {
    search() {
      this.$router.push("/search");
    },
    ndetail() {
      var id = this.active + 1;
      sessionStorage.setItem("active", JSON.stringify(id));
      this.$router.push("/navdetail/" + id).catch((e) => {});
    },
  },
  mounted() {
    this.active = JSON.parse(sessionStorage.getItem("active")) - 1;
    var token = sessionStorage.getItem("token");
    this.axios.post(url.GET_NAV_FINDALL, "token=" + token).then((res) => {
      console.log(res);
      if (res.data.code == 200) {
        this.navList = res.data.data;
      } else {
        this.$router.push("/login");
      }
    });
  },
};
</script>

<style scoped>
.div1 {
  margin-top: 40px;
}
.search {
  width: 100%;
}
</style>
